#include <cmath>
#include <cstring>
#include <iostream>
#include <set>
#include <vector>
using namespace std;
int n, m;
namespace justin_jiajia_solution_60_pts {
const int mx = 3003;
const double eps = 1e-6;
int l, v;
// l:end of the road
// v:speed limit
struct car {
  int d, v0, a;
  // d:where did the car entered
} cars[mx];
int detectors[mx];
bool excedd[mx][mx];
// int used[mx];
// vector<int> requiredd[mx];
int excnt;
void cal_excedd() {
  double disstopped, exstart;
  bool ex;
  for (int i = 0; i < n; ++i) {
    disstopped = l + 80;
    ex = false;
    if (cars[i].a < 0) {
      disstopped =
          cars[i].d - ((double)cars[i].v0 * cars[i].v0 / (cars[i].a * 2));
    }
    if (cars[i].a != 0)
      exstart = cars[i].d + ((double)v * v - (double)cars[i].v0 * cars[i].v0) /
                                (cars[i].a * 2);
    else
      exstart = (cars[i].v0 > v) ? cars[i].d : l + 80;
    // cout << i << ':' << exstart << ' ' << disstopped << '\n';
    for (int j = 0; j < m; ++j) {
      if (detectors[j] < cars[i].d) continue;
      if (disstopped - eps < (double)detectors[j]) break;
      if ((exstart - eps < (double)detectors[j] && cars[i].a >= 0) ||
          (exstart + eps > (double)detectors[j] && cars[i].a < 0)) {
        excedd[j][i] = true;
        // used[j]++;
        // requiredd[j].push_back(i);
        if (!ex) {
          ex = true;
          excnt++;
        }
      }
    }
    // if (!ex) cout << i << "not ex\n";
  }
}
int analyze() {
  int res = 0;
  set<int> catt;
  set<int> disabled;
  for (int i = 0; i < m; ++i) disabled.insert(i);
  for (int i = 0; i < n; ++i) {
    int cnt = 0, aaa;
    for (int j = 0; j < m; ++j) cnt += excedd[j][i], aaa = j;
    if (cnt == 1) {
      for (int j = 0; j < n; ++j)
        if (excedd[aaa][j]) catt.insert(j);
      disabled.erase(aaa);
    } else if (cnt == 0) {
      catt.erase(i);
    }
  }
  while (catt.size() != excnt) {
    ++res;
    int mxc = -1, mxid;
    for (int i : disabled) {
      int cur = 0;
      for (int j = 0; j < n; ++j)
        if (!catt.count(j)) cur += excedd[i][j];
      if (mxc < cur) {
        mxc = cur;
        mxid = i;
      }
    }
    // cout<<m<<' '<<mxid<<endl;
    for (int j = 0; j < n; ++j)
      if (excedd[mxid][j]) catt.insert(j);
    disabled.erase(mxid);
  }
  return disabled.size();
}
void solve() {
  excnt = 0;
  //   for (int i = 0; i < m; ++i) requiredd[i].clear();
  memset(excedd, 0, sizeof(excedd));
  //   memset(used, 0, sizeof(used));
  cin >> l >> v;
  for (int i = 0; i < n; ++i) cin >> cars[i].d >> cars[i].v0 >> cars[i].a;
  for (int i = 0; i < m; ++i) cin >> detectors[i];
  cal_excedd();
  cout << excnt << ' ' << analyze() << endl;
}
};  // namespace justin_jiajia_solution_60_pts
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  freopen("detect.in", "r", stdin);
  freopen("detect.out", "w", stdout);
  int t;
  cin >> t;
  while (t--) {
    cin >> n >> m;
    if (n <= 3000 || m <= 3000)
      justin_jiajia_solution_60_pts::solve();
    else {
      // cout << "N>=3000\n";
      justin_jiajia_solution_60_pts::solve();
    }
  }
  cout.flush();
}
// main started at 15:00
// main finished at 16:54
// excepted:60pts or lower :(